package com.forward.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Author: shafei
 * @Date: 2025/02/06 19:34
 * @description： Redis消息发布者
 **/
@Service
public class RedisMessagePublisher {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public void publish(String channel, String message) {
        redisTemplate.convertAndSend(channel, message);
        System.out.println("Message published to channel: " + channel);
    }
}
